import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import local_get from '@dfeidao/atom-web/local/get';
import local_set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
// import whoami from '@dfeidao/atom-web/msg/whoami';
import storage_get from '@dfeidao/atom-web/storage/get';
import _show from '@dfeidao/atom-web/ui/show';
import P01 from './P01';
// 功能控制点列表加载
export default async function a001(fd: IFeidaoAiBrowserComponent, args?: { formid: string, package_no: string }) {
	if (!local_get(fd, "formid")) {
		local_set(fd, "formid", args.formid);
		local_set(fd, "package_no", args.package_no);// 页面编号
	}
	// const user = await whoami();
	const prid = storage_get('productid');
	const filter = {} as { formid: string; productid: string; };
	filter.productid = prid;
	filter.formid = local_get(fd, "formid");
	// 查询
	const res = await nodejs<{ dataArray: Array<{}>, count: number }>('function-definition/zj-000004/s002', filter);
	local_set(fd, "data", res.dataArray);
	// 渲染数据
	if (res.count > 0) {
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P01"]').classList.remove('display-n');
		fd.data.node.querySelector<HTMLDivElement>('[wushujv]').classList.add('display-n');
		render(fd, res, P01, 'P01', 'inner');

	} else {
		// 如果没数据 展示空蒙版
		fd.data.node.querySelector<HTMLDivElement>('[wushujv]').classList.remove('display-n');
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P01"]').classList.add('display-n');
	}
	_show(fd.data.node);
}
